/*
 * @Author: Yang qiuyou wangyi168359476@163.com
 * @Date: 2024-07-26 11:15:02
 * @LastEditors: wanghuan wanghuan@sgsimulation.com
 * @LastEditTime: 2024-09-02 08:39:22
 * @FilePath: \SGFEM\DataStructure\FEM\Property\include\PRODData.h
 * @Description: PROD   杆截面属性定义
 *
 */

#pragma once

#include "DataStructure/Common/DataStructureNamespace.h"
#include "DataStructure/Common/Id.h"
#include "DataStructure/Common/Real.h"
#include "DataStructure/Input/Property/PropertyBase.h"
#include "DataStructure/Input/Solver/DOFDirections.h"

SG_DATASTRUCTURE_FEM_NAMESPACE_OPEN
/// @brief 杆截面属性定义
///
/// 支持对杆截面拉压和扭转描述
struct PRODData : PropertyBase
{
    SG::DataStructure::Common::Id   m_mId                 = 0;    ///< 材料属性
    SG::DataStructure::Common::Real m_area                = 0.0;  ///< 截面积
    SG::DataStructure::Common::Real m_torsionFactor       = 0.0;  ///< 扭转常数
    SG::DataStructure::Common::Real m_torsionStressfactor = 0.0;  ///< 扭转切应力系数
    SG::DataStructure::Common::Real m_nsm                 = 0.0;  ///< 非结构质量
    SG::DataStructure::Common::Id   m_domainId            = 0;

    DofSet GetActiveDofs () const
    {
        if (m_area > 1.0e-12 && m_torsionFactor > 1.0e-12)
        {
            return getAllNodeDofs ();
        }

        if (m_area > 1.0e-12)
        {
            return { DOF_Ux, DOF_Uy, DOF_Uz };
        }

        if (m_torsionFactor > 1.0e-12)
        {
            return { DOF_Rotx, DOF_Roty, DOF_Rotz };
        }

        // 此时截面积和扭转刚度系数均为0.0
        return {};
    }
};

DECLSPEC bool operator== (const PRODData &a, const PRODData &b);

SG_DATASTRUCTURE_FEM_NAMESPACE_CLOSE
